// pages/manager_user/index.js

import {
  requst_get_getConfigInfo,
  requst_post_setConfigInfo
} from '../../utils/api.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
this.getConfig()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  bindKeyInput1: function (e) {

    this.setData({
      ['configInfo.homeTitle1']:e.detail.value
    })
  },
  bindKeyInput2: function (e) {
 
    this.setData({
      ['configInfo.homeSubTitle1']:e.detail.value
    })
  },
  bindKeyInput3: function (e) {
   
    this.setData({
      ['configInfo.homeTitle2']:e.detail.value
    })
  },
  bindKeyInput4: function (e) {
 
    this.setData({
      ['configInfo.homeSubTitle2']:e.detail.value
    })
  },
  bindKeyInput5: function (e) {
  
    this.setData({
      ['configInfo.version']:e.detail.value
    })
  },
  bannerImage: function (e) {
  
    this.setData({
      ['configInfo.bannerImage']:e.detail.value
    })
  },
  bannerpath: function (e) {
  
    this.setData({
      ['configInfo.bannerpath']:e.detail.value
    })
  },
  getConfig:function(){
    var that = this;
    const params = {
    }
    requst_get_getConfigInfo(params).then(res => {
      that.setData({
        configInfo: res.data
      })
    }).catch(err => {
    })
  },
  saveconfig:function(){
    var that = this;
    const params = {
      homeTitle1:this.data.configInfo.homeTitle1,
      homeSubTitle1:this.data.configInfo.homeSubTitle1,
      homeTitle2:this.data.configInfo.homeTitle2,
      homeSubTitle2:this.data.configInfo.homeSubTitle2,
      version:this.data.configInfo.version,
      bannerImage:this.data.configInfo.bannerImage,
      bannerpath:this.data.configInfo.bannerpath
    }
    requst_post_setConfigInfo(params).then(res => {
      wx.showToast({
        title: '保存成功',
      })
    }).catch(err => {
    })
  }
})